import React,  { useState, useEffect } from 'react'
import PropTypes from 'prop-types'
import { Pagination  } from 'antd'
import '../static/style/components/Pagination.scss'
function PaginationTmp(prop) {
  const [props, setProps] = useState(prop)
  const [current, setcurrent] = useState(prop.current)
  useEffect(()=>{
    setcurrent(prop.current)
    console.log('565665656',prop);
  },[prop.current])
  const PaginationSizeChanger = (page, pageSize) => {
    setcurrent(page)
    props.PaginationSizeChanger(page, pageSize)
  }
  return (
    <div className="Pagination">
      <Pagination
        total={prop.total}
        className="antd-pagination"
        current={current}
        onChange = { PaginationSizeChanger }
        defaultPageSize={10}
        showTotal={() => `共 ${prop.total} 条`}
      />
    </div>
  )
}

PaginationTmp.propTypes = {
  total: PropTypes.number.isRequired,
  current: PropTypes.number
}
// PaginationTmp.defaultProps = {
//   total: 0
// }
export default PaginationTmp
